local limitKey = KEYS[1]
local holdKey = KEYS[2]
local storeKey = KEYS[3]
local uid = ARGV[1]
local maxLimit = ARGV[2]
local exits = tonumber(redis.call('exists', holdKey))
if exits == 1 then
    return -1
end
local limit = tonumber(maxLimit)
local current = tonumber(redis.call('get', limitKey) or "0")
if current + 1 > limit then
    return -2
end
redis.call('incrby', limitKey, '1')
redis.call('expire', limitKey, '2')
local store = tonumber(redis.call('get', storeKey))
if store <= 0 then
    return -3
end
local leftStore = tonumber(redis.call('decrby', storeKey, '1'))
redis.call('set', holdKey, uid)
return leftStore